{% if not post.private %}
    <h3 class="d-flex justify-content-between">
        <div>
        {{ comments|length }}
        {{ ngettext('comment', 'comments', __num=comments|length) }}
        </div>
        <small>
            <a href="{{ url_for('main.full_post', id=post.id, page=pagination.pages or 1) }}#comments">
                {{ _("latest") }}
            </a>
        </small>
    </h3>
    {% if current_user.is_authenticated %}
        {{ render_form(form) }}
    {% endif %}
    {% if comments %}
        <ul class="list-group">
        {% for comment in pagination.items %}
            <li class="list-group-item list-group-item-action flex-column">
            <div class="d-flex w-100 justify-content-between">
                <h5 class="mb-1">
                    {% if comment.author != None %}
                        <a href="{{ comment.author.profile_url() }}" target="_blank">
                            <img class="avatar" src="{{ comment.author.avatar_url() }}">
                            {{ comment.author.username }}
                        </a>
                    {% else %}
                        <span>{{ _("Deleted Flog User") }}</span>
                    {% endif %}
                </h5>
                {% if comment.author.is_administrator() %}
                <span class="badge badge-danger">{{ _("Admin") }}</span>
                {% endif %}
                {% if comment.author == post.author %}
                <span class="badge badge-primary">{{ _("Author") }}</span>
                {% endif %}
                <small data-toggle="tooltip" data-placement="top" data-delag="500"
                    data-timestamp="{{ comment.timestamp.strftime('%Y-%m-%dT%H:%M:%SZ') }}">
                    {{ moment(comment.timestamp).fromNow() }}
                </small>
            </div>
            {% if comment.replied %}
            <div class="alert alert-dark reply-body bg-dark-gray">
                {{ comment.replied.author.username }}:<br>
                {{ comment.replied.body | safe }}
            </div>
            {% endif %}
            <p class="mb-1">{{ comment.body | safe }}</p>
            {% if current_user.is_authenticated %}
                <div class="d-flex justify-content-end">
                    {% if current_user.is_administrator() or current_user == comment.author %}
                    <form class="form-inline" method="POST" action="{{ url_for('main.delete_comment', comment_id=comment.id) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                        <button class="btn btn-sm btn-danger" onclick="return confirm('{{ _('Are you sure?') }}');">
                            <i class="bi-trash"></i>
                            {{ _("DELETE") }}
                        </button>
                    </form>
                    {% endif %}
                    <a class="btn btn-light btn-sm" href="{{ url_for('main.reply_comment', comment_id=comment.id, author=comment.replied.author) }}">
                        <i class="bi-reply"></i>
                        {{ _("Reply") }}
                    </a>
                </div>
            {% endif %}
            </li>
        {% endfor %}
        </ul>
        {{ render_pagination(pagination) }}
        {% if request.args.get('reply') and current_user.is_authenticated %}
            <div class="alert alert-dark" id="reply-comment-form">
                <i class="bi-mail-reply"></i>{{ _("Reply to") }}
                <b>{{ replied_comment.author.username }}</b>:
                <a class="float-right btn btn-light btn-sm" href="{{ post.url() }}">
                    <i class="bi-x"></i>
                </a>
                {{ render_form(form) }}
            </div>
        {% endif %}
    {% else %}
        {{ _("No comments yet.") }}
    {% endif %}
{% else %}
    {{ _("You cannot comment a private post!") }}
{% endif %}